<!--
 * @Author: your name
 * @Date: 2022-04-14 10:44:08
 * @LastEditTime: 2022-04-14 11:02:25
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\url参数解析成一个对象220414.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var url="geyao?key0=0&key1=1&key2=2&key3=3"

    function parseQueryString(url){
      var str=url.split("?")[1]
      var items=str.split("&")
      var result=[]
      var arr=[]
      for(var i=0;i<items.length;i++){
        arr=items[i].split("=")
        result[arr[0]]=arr[1]
      }
      return result
    }
    var obj=parseQueryString(url)
    console.log(obj,"obj")
    //[key0: '0', key1: '1', key2: '2', key3: '3'] 'obj'
  </script>
</body>
</html>